package com.colorlight.cloud.grandshow.entity.po;

import com.colorlight.cloud.gateway.api.message.constraint.basics.object.Trans;
import com.colorlight.iot.proto.grandshow.entity.GrandShowEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author Demon
 * @description 加密的细节
 * @date 6/5/2024  上午8:52
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthorizationDetail implements Trans<AuthorizationDetail, GrandShowEntity.AuthorizationDetail> {
    private String password;

    @Override
    public GrandShowEntity.AuthorizationDetail toProto() {
        GrandShowEntity.AuthorizationDetail.Builder builder = GrandShowEntity.AuthorizationDetail.newBuilder();

        if (Objects.nonNull(this.getPassword())) {
            builder.setPassword(this.getPassword());
        }

        return builder.build();
    }

    @Override
    public AuthorizationDetail formProto(GrandShowEntity.AuthorizationDetail authorizationDetail) {
        this.setPassword(authorizationDetail.getPassword());
        return this;
    }
}
